// ==================================================================================
// Shared Genomics Project MPI Codebase
// Version 1.0 30/04/2010
//
// (c) 2010 University of Manchester all rights reserved
//
// This file is distributed under the GNU General Public License, Version 2.  
// Please see the file COPYING.txt for more details
// ==================================================================================

/*!
\file
\brief Binary BT Association (BitStrings)
*/
#ifndef _PASSOC_BT_H_
#define _PASSOC_BT_H_

#include <stdio.h>

#include "adjusted.h"
#include "bitstring.h"
#include "bmapfile.h"
#include "sample.h"
#include "types.h"

#ifdef __cplusplus
extern "C" {
#endif

/*! 
\brief Write Header to output file.
\details
	The final confidence interval label is dependent on the variable \ref selected_options::ci_level .
\param [in,out] out Text output file handle
\param [in] ops Confidence Interval Setting 
\sa selected_options::ci_level
*/
void passoc_bt_write_file_header(FILE *out, struct selected_options *ops);

/*! 
\brief Calculate test statistic for Binary Trait Association (BitString)
\details
	The allelic data is stored as bit string and is accessed by shift operations.<br>
	This function will write data to file if the output file handle is not set to NULL.<br>
	If this function is used to perform a calculation, leave the file handle and
	the adjusted p-value structure set to NULL.
\param [in] X Flag if SNP on sex chromosome
\param [in] haploid Flag if SNP is haploid
\param [in] ones_and_twos BitString of Allelic Data of a SNP
\param [in] samples The Samples Array
\param [in] nSamples Size of the Samples Arrays
\param [in] snp Pointer to the current SNP
\param [in,out] out File Handle to text output file
\param [in] emp1 Empirical P-value from randomised data
\param [in] emp2 Family Wide Error Rate (FWER) from randomised data
\param [in] zt A z-score associated with the calculation of a confidence interval
\param [in] adj Structure containing adjusted p-values for multiple testing.
*/
double passoc_bt_assoc(BOOL X, BOOL haploid, BitString ones_and_twos, struct sample *samples, int nSamples, struct small_locus *snp, FILE *out, double emp1, double emp2, double zt, struct adjusted *adj);

#ifdef __cplusplus
}
#endif

#endif // _PASSOC_BT_H_